#pragma once

#include <base/base_hdef.h>

/* 机器无关的类型 */
typedef unsigned int		uint_t;
typedef unsigned long		ulong_t;
typedef unsigned long long	  ullong_t;
typedef long long		long_t;
typedef long long		llong_t;

typedef __UINT64_TYPE__		uint64_t;
typedef unsigned int		uint32_t;
typedef unsigned short		uint16_t;
typedef unsigned char		uint8_t;

typedef __INT64_TYPE__		int64_t;
typedef int			int32_t;
typedef short			int16_t;
typedef signed char		int8_t;

// typedef __uint128_t		uint128_t;

/* 机器无关的定义 */
typedef _Bool			bool_t;

typedef unsigned char		byte_t;
typedef byte_t			uchar_t;

typedef __UINTPTR_TYPE__	paddr_t;
typedef __SIZE_TYPE__		size_t;
/* 核心id */
typedef unsigned int		cid_t;
typedef unsigned int		tid_t;

#define NULL_PTR		((void *)0)

#ifndef TRUE 
	#define TRUE		(1)
#endif
#ifndef FALSE
	#define FALSE		(0)
#endif

/* _Static_assert(sizeof(void *) == sizeof(word_t), "sizeof void* != sizeof word_t"); */

static inline word_t dword_high(dword_t t){
	// return (word_t)(t >> WORD_WIDTH);
	return t.hword;
}
static inline word_t dword_low(dword_t t){
	// return t;
	return t.lword;
}

static inline hword_t word_high(word_t t){
	return (hword_t)(t >> HWORD_WIDTH);
}
static inline hword_t word_low(word_t t){
	return (hword_t)(t);
}

/* 构造word */
static inline word_t new_word(hword_t high,hword_t low){
	return (((word_t)high) << HWORD_WIDTH) | ((word_t)low);
}
static inline dword_t new_dword(word_t high,word_t low){
	// return (((dword_t)high) << WORD_WIDTH) | ((dword_t)low);
	return (dword_t){.lword = low, .hword = high};
}
